package jcommon.beans4ex;

import java.awt.Color;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class Person  extends  BaseBean{

	private String name;

	private Integer age;

	private Color favouriteColor;

	private List<String> favouriteFoods = new ArrayList<String>();

	private Map<String, Person> familyRelation = new HashMap<String, Person>();

	private Job job;

	public static Comparator<Person> cparator = new Comparator<Person>() {
		public int compare(Person o1, Person o2) {
			Integer age1 = o1.getAge();
			Integer age2 = o2.getAge();
			try {
				return age1 - age2;
			} catch (NullPointerException npe) {
				if (age1 == 0 && age2 == 0) {
					return 0;
				} else if (age1 == 0) {
					return 1;
				} else
					return -1;
			}
		}
	};

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Integer getAge() {
		return age;
	}

	public void setAge(Integer age) {
		this.age = age;
	}

	public Job getJob() {
		return job;
	}

	public void setJob(Job job) {
		this.job = job;
	}

	public Color getFavouriteColor() {
		return favouriteColor;
	}

	public void setFavouriteColor(Color favouriteColor) {
		this.favouriteColor = favouriteColor;
	}

	public List<String> getFavouriteFoods() {
		return favouriteFoods;
	}

	public void addFavouriteFood(String foodName) {
		getFavouriteFoods().add(foodName);
	}

	public Map<String, Person> getFamilyRelation() {
		return familyRelation;
	}

	public void addFamilyRelation(String relation, Person person) {
		familyRelation.put(relation, person);
	}
}
